<?php
/**
 * 根据trade执行BUY操作。
 * TransHistory
 */
require 'config.php';
require 'Lib_btc.php';

$orders = getToCancelOrders();
$i=0;$j=0;
if( !empty($orders) )
	foreach( $orders AS $i=>$order )
{
	$result = btce_query("CancelOrder",
					array("order_id" => $order['order_id'])
			);
	if( !empty($result) && $result['success'] == BTC_API_SUCCESS )
	{
		$i++;
		$return = $result['return'];
		if( $order['type'] == BTC_TRADE_TYPE_BUY )cancelOrder( $return['order_id'] );
		else cancelSell($return['order_id']);
	}else $j++;
}
logBtcApiResult('CancelOrder','作废成功'.$i.'个；作废失败'.$j.'个；');
echo "<script>
<!--
setTimeout(function(){location.replace(location.href);},300000);
//-->
</script>";
?>
